home *** CD-ROM | disk | FTP | other *** search
- Path: colossus.holonet.net!russell
- From: russell@news.mdli.com (Russell Blackadar)
- Newsgroups: comp.lang.c++
- Subject: Re: Question: references to variables within classes
- Date: 12 Jan 1996 23:23:40 GMT
- Organization: HoloNet National Internet Access System: 510-704-1058/modem
- Message-ID: <4d6qhs$ie@colossus.holonet.net>
- References: <DKy0MC.3nA@watserv3.uwaterloo.ca>
- NNTP-Posting-Host: jubal.mdli.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Stephen Bay (sdbay@watnow.uwaterloo.ca) wrote:
- : Hi,
-
- : Is it possible in C++ to use variables within a class as
- parameters for a
- : constructor of an object contained within that class? I've
- tried compiling the
-
- (deleted stuff)
-
- : class dodo
- : {
- : public:
- : NISList<int *> CityList;
- : chokes here-> NISListIter<int *> CityListIter(CityList);
- : }; ^^^^^^^^^^
-
- The underlined stuff is an initializer. This is not legal
- inside a class definition. Instead, you need to do the
- initialization in dodo's constructor, e.g.
-
- dodo::dodo() : CityList(), CityListIter(CityList) {}
-
- So, the answer to your question is yes, if you do it legally.
- --
- Russell Blackadar, russell@mdli.com
-